package visitor;

import visitor.interf.Visitor;

public class VisitorPattern {
    public static void main(String[] args) {
        //对象结构角色
        ObjectStructure os = new ObjectStructure();
        os.add(new ConcreteElementA());
        os.add(new ConcreteElementB());

        //具体访问者A类
        Visitor visitor = new ConcreteVisitorA();
        os.accept(visitor);

        System.err.println("------------------------");

        //具体访问者B类
        visitor = new ConcreteVisitorB();
        os.accept(visitor);
    }
}
